package utils;


import dto.FileDto;
import error.FileErrorCode;
import error.FileServiceException;
import lombok.extern.slf4j.Slf4j;
import org.csource.common.MyException;

import java.io.IOException;


/**
 *
 * @author xj
 * @since 1.0
 */
@Slf4j
public class FileDownLoadUtil {

    public static byte[] download(FileDto dto){
        try {
            return FileUtil.getStorageClient().download_file(dto.getFileGroupPath(),dto.getFileUrl());
        } catch (IOException | MyException e) {
            log.error("fdfs下载IOException:{0}", e);
            throw  new FileServiceException(FileErrorCode.FILE_SERVER_CONNTION_FAILE);
        }
    }
}
